<?php echo $this->partial("sidebar.phtml", array('type' => 'product', 'cartdata' => $this->cartdata, 'params' => $this->params)); ?>

<div class="product-detail-grid-block products-scroller isotope-big" style="background:#F0F0F0 url('<?php echo BRANDS_PATH; ?>/display/<?php echo $this->alldata[0]['display_image']; ?>') no-repeat left center;background-size:100%;">
    <div class="diamond-logo-description product-block">
        <img src="<?php echo BRANDS_PATH; ?>/logo/<?php echo @$this->alldata[0]['logo_image']; ?>" alt="image" class="logo-image"/>
    </div>
    <div class="product-left-section product-block" style="padding-right: 20px;">
        <div class="product-and-scroller text-center">
<!--            <img src="<?php echo IMAGES_PATH; ?>/product.jpg" alt="image" class="main"/>
            <img src="<?php echo IMAGES_PATH; ?>/product-scroller.jpg" alt="image" class="scroller"/>-->

            <ul class="bxslider">
                <?php
                    $images = $this->alldata[0]['images'];
                    $images = explode(",", $images);
                    foreach ($images as $iVal)
                    {
                        ?>
                        <li><img src="<?php echo PRODUCTS_PATH; ?>/<?php echo $iVal; ?>" data-zoom-image="<?php echo PRODUCTS_PATH; ?>/<?php echo $iVal; ?>" style="height:300px;"/></li>
                        <?php
                    }
                ?>
            </ul>

            <div id="bx-pager">
                <?php
                    foreach ($images as $iVal)
                    {
                        ?>
                        <a data-slide-index="0" href=""><img src="<?php echo PRODUCTS_PATH; ?>/<?php echo $iVal; ?>" /></a>
                        <?php
                    }
                ?>
            </div>
        </div>

        <div class="pull-right margin-top-40">
            <!-- AddThis Button BEGIN -->
            <div class="addthis_toolbox addthis_default_style ">
                <a class="addthis_button_preferred_1"></a>
                <a class="addthis_button_preferred_2"></a>
                <a class="addthis_button_preferred_3"></a>
                <a class="addthis_button_preferred_4"></a>
                <a class="addthis_button_compact"></a>
                <a class="addthis_counter addthis_bubble_style"></a>
            </div>
            <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-525124772e13082f"></script>
            <!-- AddThis Button END -->
        </div>
    </div>
    <?php
        $size = explode(',', $this->alldata[0]['size']);
        $stock = $this->alldata[0]['size_json'];
        $stock = (array) json_decode($stock);
    ?>
    <script type="text/javascript">
        var sizeQty = [];
        var sizeqty =  JSON.parse('<?php echo $this->alldata[0]['size_json']; ?>');
        for(var i in sizeqty){
            sizeQty[i] = sizeqty[i];
        }
    </script>
    <div class="product-middle-section product-block vertical-scroller">
        <p class="product-title"><?php echo $this->alldata[0]['prod_name']; ?></p>
        <p class="review-text">
            <span class="raty" data-score="<?php echo round($this->reviewdata[0]['avg_review']); ?>" style="vertical-align: text-bottom;"></span>
            <?php echo count($this->reviewdata); ?> Review(s) | <a href="#" class="colorbox-inline" rel="review-popup" style="color: #969DA5;">Add your review</a></p>

        <div class="availability-section">
            <p><span class="info-title">Availability:</span><span class="color-orange instock"><?php echo $stock[$size[0]] > 0 ? 'Instock' : 'Out of stock'; ?></span></p>
            <p><span class="info-title">Product Code:</span><?php echo $this->alldata[0]['prod_code']; ?></p>

            <hr/>

            <p class="product-desc-title">Product Description</p>
            <p class="product-desc-text"><?php echo $this->alldata[0]['short_desc']; ?></p>

            <hr/>

            <p class="price-text">$<?php echo $this->alldata[0]['price']; ?></p>

            <div class="cart-options">
                <form action="<?php echo $this->baseUrl('product/addtocart') ?>">
                    <input type="hidden" name="product_id" class="product_id" value="<?php echo $this->alldata[0]['rkn_prod_id']; ?>"/>
                    <input type="hidden" name="brand_id" class="product_brand_id" value="<?php echo $this->alldata[0]['brand_id']; ?>"/>
                    <input type="hidden" name="color" class="product_color" value="<?
            $color = explode(',', $this->alldata[0]['color']);
            echo $color[0];
            ?>"/>
                    <p>Quantity:</p>

                    <div class="btn-group">
                        <button type="button" class="btn btn-default prod-quant-dec-btn" data-quantity = "<?php echo $stock[$size[0]]; ?>" onclick="decrementQuantity(this);">-</button>
                        <input type="text" name="quantity" class="btn btn-default prod-quant-input" value="<?php echo ($stock[$size[0]]) ? '1' : '0'; ?>"/>
                        <button type="button" class="btn btn-default prod-quant-inc-btn"  data-quantity = "<?php echo $stock[$size[0]]; ?>" onclick="incrementQuantity(this);">+</button>
                    </div>

                    <p>Color:</p>
                    <div class="colors" style="width:45px;">
                        <?php
                            if (count($color) > 0)
                                foreach ($color as $cVal)
                                {
                                    ?>
                                    <span style="background-color: <?php echo $cVal; ?>;" id="<?php echo $cVal; ?>" class="active"></span>
                                    <?php
                                }
                        ?>
                    </div>

                    <br/>

                    <p>Size:</p>
                    <select class="size-select" name="size" onchange="updatestock(this.value)">
                        <?php
                            if (count($size) > 0)
                                foreach ($size as $sVal)
                                {
                                    ?>
                                    <option value="<?php echo $sVal; ?>"><?php echo $sVal; ?></option>
                                    <?php
                                }
                        ?>
                    </select>

                    <br/>
                    <br/>
                    <button type="submit" class="add-to-cart <?php echo $stock[$size[0]] ? '' : 'hide'; ?>">Add to cart</button>
                </form>
            </div>
        </div>

    </div>

    <div class="product-right-section product-block">
        <?php echo nl2br($this->alldata[0]['full_desc']); ?>
    </div>
    <!-- Brand Feature Block -->
    <?php
        echo $this->partial('brand_features.phtml', array('brandFeatures' => $this->brandFeatures, 'display' => true, 'type' => 'product'));
    ?>
    <div class="reviewDiv  product-block" style="background-color:#F0F0F0;">
        <div class="review-list">
            <div class="reviewDiv-upper">
                <button type="button" id="write-review" class="btn btn-raeken pull-right">WRITE A REVIEW</button>
                <p class="title"><?php echo count($this->reviewdata); ?> REVIEWS</p>
                <p class="review-text">
                    <span class="raty" data-score="<?php echo count($this->reviewdata) > 0 ? round($this->reviewdata[0]['avg_review']) : 0; ?>" style="vertical-align: text-bottom;"></span>
                    <span class="color-orange" style="font-weight:bold;">(<?php echo count($this->reviewdata) > 0 ? round($this->reviewdata[0]['avg_review'], 2) : 0; ?>)</span>
                </p>
            </div>
            <div class="reviewDiv-lower use-scroller">
                <ul class="review-wrap ">
                    <?php
                        if (!empty($this->reviewdata))
                            foreach ($this->reviewdata as $revKey => $revVal)
                            {
                                ?>
                                <li class="review-box">
                                    <div class="right-part pull-left">
                                        <p><?php echo $revVal['review_text']; ?></p>
                                    </div>
                                    <div style="width:100%;display:inline-block;">
                                        <span class="raty pull-left" data-score="<?php echo $revVal['review_rating']; ?>" style="vertical-align: text-bottom;"></span>
                                        <span class="review-date pull-right"><?php echo date('F j, Y', strtotime($revVal['review_date'])); ?></span>
                                        <!--<span class="review-date pull-right">April 20, 2014</span>-->
                                    </div>
                                </li>
                                <?php
                            }
                    ?>
                </ul>
            </div>
        </div>

    </div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
    
        //if($('.validate-review-form')[0])
        var to_print_html = '<div class="popup-review-box">';
        to_print_html += '<h2 style="margin:0;">Write A Review</h2>';
        to_print_html += '<div>';
        to_print_html += '<form name="myform" class="review myform validate-form" method="post" novalidate="novalidate">';
        to_print_html += '<ol class="review-input">';
        to_print_html += '<li data-counter="1">';
        to_print_html += 'What do you think about this item?<br>';
        to_print_html += '<div class="raty" data-score="0" style="margin-left: 25px;"></div>';
        to_print_html += '</li>'
        to_print_html += '<li data-counter="2">';
        to_print_html += 'What do you think about this item (Comment)?<br>';
        to_print_html += '<div class="form-group">';
        to_print_html += '<textarea name="review_text" id="review_text" class="required form-control" placeholder="Write review here" rows="5" required="required"></textarea>';
        to_print_html += '</div>';
        to_print_html += '</li>';
        to_print_html += '</ol>';
        to_print_html += '<button type="submit" name="submit" class="btn btn-orange">SUBMIT REVIEW</button>';
        to_print_html += '</form>';
        to_print_html += '</div>';
        to_print_html += '</div>';
    
    
        $('.colorbox-inline, #write-review').click(function(){
            $.colorbox({
                html: to_print_html,
                width: "50%",
                //                height: "100%",
                scrolling:false
            });
            
            validateForm();
            
            ratyPlugin();
        });
    
    })

</script>